﻿<%@ WebHandler Language="C#" Class="getReportTypeHandler" %>

using System;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Web.Script.Serialization;
using System.IO;
using System.Runtime.Serialization.Json;

public class getReportTypeHandler : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {

        //int type = 0;
        //type = int.Parse(context.Request.QueryString["typeId"]);
        RtypeEntity model;
        List<RtypeEntity> list = new List<RtypeEntity>();


        string str = System.Configuration.ConfigurationManager.ConnectionStrings["decheatConnectionString"].ToString();
        string sql = "select * from  Dyh_type where Delete_flag=0";
        SqlConnection conn = new SqlConnection(str);
        conn.Open();
        SqlCommand comm = new SqlCommand(sql, conn);
        System.Data.DataSet ds = new DataSet();
        SqlDataReader dr = comm.ExecuteReader();
        while (dr.Read())
        {

            string name = dr["type"].ToString();
            int id = int.Parse(dr["id"].ToString());
            //Console.WriteLine(name + ":" + type);
            model = new RtypeEntity(id, name, "");
            list.Add(model);
        }
        //JsonHelper.GetJson<List<Tongji>

        dr.Close();
        if (conn.State == ConnectionState.Open)
        {
            conn.Close();
        }
        //JavaScriptSerializer json = new JavaScriptSerializer();
        string result = WebUI.CommonClass.JSONHelper.Obj2Json<List<RtypeEntity>>(list);
        context.Response.ContentType = "text/plain";
        context.Response.Write(result);
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}